//
//  NetworkVC.m
//  SYPerfectDemo
//
//  Created by Lssyyy on 2018/12/25.
//  Copyright © 2018年 Lssyyy. All rights reserved.
//

#import "NetworkVC.h"
#import <AFNetworking/AFNetworking.h>
@interface NetworkVC ()

@end

@implementation NetworkVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //二维码参数
    //    NSString *tradetime = [self getCurrentTime];
    //    NSString *serialId = [NSString stringWithFormat:@"qdzx_qrcode_serial number_%@",tradetime];
    //    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    //    dic[@"type"] = @"1";
    //    dic[@"cardId"] = @"3130856957";
    //    dic[@"tradetime"] = tradetime;
    //    dic[@"serialId"] = serialId;
    
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    dic[@"os"] = @"1";
    dic[@"city_id"] = @"1";
    [self requestBBB:dic];
}

- (void)requestBBB:(NSDictionary*)dic{
    //1.确定请求路径
    NSString *urlStr = @"http://xingmintong.starrypay.com:18011/app-core/queryIndexShowAppAppList";
//    https://htspower.com/app/mobileMember!getOxygenKitMusicTime.do
//    https://kyfw.12306.cn/otn
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.securityPolicy.allowInvalidCertificates= YES;
    manager.securityPolicy.validatesDomainName = NO;
//    manager.requestSerializer = [AFHTTPRequestSerializer serializer];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];
    
    [manager.requestSerializer setValue:@"utf-8" forHTTPHeaderField:@"charset"];
    [manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [manager GET:urlStr parameters:dic progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"2百百百%@---%@",[responseObject class],responseObject);
        NSLog(@"3百百百%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
         NSLog(@"4错误%@",error);
    }];
//    [manager POST:urlStr parameters:dic progress:^(NSProgress * _Nonnull uploadProgress) {
//        NSLog(@"1百百百%@",uploadProgress);
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"2百百百%@---%@",[responseObject class],responseObject);
//        NSLog(@"3百百百%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSLog(@"4错误%@",error);
//    }];
}


- (NSString *)getCurrentTime{
    NSDate *nowDate = [NSDate date];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyyMMddHHmmss"];
    NSString *dateStr = [formatter stringFromDate:nowDate];
    NSLog(@"当前北京时间%@",dateStr);
    return dateStr;
}
@end
